
-- --------------------------------------------------
-- Entity Designer DDL Script for SQL Server 2005, 2008, 2012 and Azure
-- --------------------------------------------------
-- Date Created: 11/27/2015 19:01:00
-- Generated from EDMX file: D:\01_Pro\Clients\CICM\RecruitmentProfiler\CodeSource\Dev\CICM.RecruitmentProfiler\CICM.RecruitmentProfiler.Services\Model.edmx
-- --------------------------------------------------

SET QUOTED_IDENTIFIER OFF;
GO
USE [RecruitmentProfiler];
GO
IF SCHEMA_ID(N'dbo') IS NULL EXECUTE(N'CREATE SCHEMA [dbo]');
GO

-- --------------------------------------------------
-- Dropping existing FOREIGN KEY constraints
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[FK_FormesJuridiqueEntreprises_FormesJuridique]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FormesJuridiqueEntreprises] DROP CONSTRAINT [FK_FormesJuridiqueEntreprises_FormesJuridique];
GO
IF OBJECT_ID(N'[dbo].[FK_FormesJuridiqueEntreprises_Entreprises]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[FormesJuridiqueEntreprises] DROP CONSTRAINT [FK_FormesJuridiqueEntreprises_Entreprises];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsEntreprises_Contacts]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsEntreprises] DROP CONSTRAINT [FK_ContactsEntreprises_Contacts];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsEntreprises_Entreprises]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsEntreprises] DROP CONSTRAINT [FK_ContactsEntreprises_Entreprises];
GO
IF OBJECT_ID(N'[dbo].[FK_MissionsEntreprises]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[Missions] DROP CONSTRAINT [FK_MissionsEntreprises];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsCVs_Contacts]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsCVs] DROP CONSTRAINT [FK_ContactsCVs_Contacts];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsCVs_CVs]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsCVs] DROP CONSTRAINT [FK_ContactsCVs_CVs];
GO
IF OBJECT_ID(N'[dbo].[FK_CVEnvoyesMissions_CVEnvoyes]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CVEnvoyesMissions] DROP CONSTRAINT [FK_CVEnvoyesMissions_CVEnvoyes];
GO
IF OBJECT_ID(N'[dbo].[FK_CVEnvoyesMissions_Missions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CVEnvoyesMissions] DROP CONSTRAINT [FK_CVEnvoyesMissions_Missions];
GO
IF OBJECT_ID(N'[dbo].[FK_CVsCVEnvoyes_CVs]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CVsCVEnvoyes] DROP CONSTRAINT [FK_CVsCVEnvoyes_CVs];
GO
IF OBJECT_ID(N'[dbo].[FK_CVsCVEnvoyes_CVEnvoyes]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[CVsCVEnvoyes] DROP CONSTRAINT [FK_CVsCVEnvoyes_CVEnvoyes];
GO
IF OBJECT_ID(N'[dbo].[FK_EntreprisesProspection_Entreprises]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EntreprisesProspection] DROP CONSTRAINT [FK_EntreprisesProspection_Entreprises];
GO
IF OBJECT_ID(N'[dbo].[FK_EntreprisesProspection_Prospection]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EntreprisesProspection] DROP CONSTRAINT [FK_EntreprisesProspection_Prospection];
GO
IF OBJECT_ID(N'[dbo].[FK_MissionsProspection_Missions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MissionsProspection] DROP CONSTRAINT [FK_MissionsProspection_Missions];
GO
IF OBJECT_ID(N'[dbo].[FK_MissionsProspection_Prospection]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[MissionsProspection] DROP CONSTRAINT [FK_MissionsProspection_Prospection];
GO
IF OBJECT_ID(N'[dbo].[FK_EntreprisesContratsRecruteurs_Entreprises]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EntreprisesContratsRecruteurs] DROP CONSTRAINT [FK_EntreprisesContratsRecruteurs_Entreprises];
GO
IF OBJECT_ID(N'[dbo].[FK_EntreprisesContratsRecruteurs_ContratsRecruteurs]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EntreprisesContratsRecruteurs] DROP CONSTRAINT [FK_EntreprisesContratsRecruteurs_ContratsRecruteurs];
GO
IF OBJECT_ID(N'[dbo].[FK_ProspectionEntretiens_Prospection]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProspectionEntretiens] DROP CONSTRAINT [FK_ProspectionEntretiens_Prospection];
GO
IF OBJECT_ID(N'[dbo].[FK_ProspectionEntretiens_Entretiens]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ProspectionEntretiens] DROP CONSTRAINT [FK_ProspectionEntretiens_Entretiens];
GO
IF OBJECT_ID(N'[dbo].[FK_EntretiensDetailEntretiens_Entretiens]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EntretiensDetailEntretiens] DROP CONSTRAINT [FK_EntretiensDetailEntretiens_Entretiens];
GO
IF OBJECT_ID(N'[dbo].[FK_EntretiensDetailEntretiens_DetailEntretiens]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[EntretiensDetailEntretiens] DROP CONSTRAINT [FK_EntretiensDetailEntretiens_DetailEntretiens];
GO
IF OBJECT_ID(N'[dbo].[FK_ContratsRecruteursMissions_ContratsRecruteurs]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContratsRecruteursMissions] DROP CONSTRAINT [FK_ContratsRecruteursMissions_ContratsRecruteurs];
GO
IF OBJECT_ID(N'[dbo].[FK_ContratsRecruteursMissions_Missions]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContratsRecruteursMissions] DROP CONSTRAINT [FK_ContratsRecruteursMissions_Missions];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsRoles_Contacts]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsRoles] DROP CONSTRAINT [FK_ContactsRoles_Contacts];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsRoles_Roles]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsRoles] DROP CONSTRAINT [FK_ContactsRoles_Roles];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsProspection_Contacts]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsProspection] DROP CONSTRAINT [FK_ContactsProspection_Contacts];
GO
IF OBJECT_ID(N'[dbo].[FK_ContactsProspection_Prospection]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ContactsProspection] DROP CONSTRAINT [FK_ContactsProspection_Prospection];
GO
IF OBJECT_ID(N'[dbo].[FK_ListePaysContacts_ListePaysObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ListePaysContacts] DROP CONSTRAINT [FK_ListePaysContacts_ListePaysObject];
GO
IF OBJECT_ID(N'[dbo].[FK_ListePaysContacts_ContactsObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ListePaysContacts] DROP CONSTRAINT [FK_ListePaysContacts_ContactsObject];
GO
IF OBJECT_ID(N'[dbo].[FK_ListePaysEntreprises_ListePaysObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ListePaysEntreprises] DROP CONSTRAINT [FK_ListePaysEntreprises_ListePaysObject];
GO
IF OBJECT_ID(N'[dbo].[FK_ListePaysEntreprises_EntreprisesObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[ListePaysEntreprises] DROP CONSTRAINT [FK_ListePaysEntreprises_EntreprisesObject];
GO
IF OBJECT_ID(N'[dbo].[FK_RolesEntreprises_RolesObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RolesEntreprises] DROP CONSTRAINT [FK_RolesEntreprises_RolesObject];
GO
IF OBJECT_ID(N'[dbo].[FK_RolesEntreprises_EntreprisesObject]', 'F') IS NOT NULL
    ALTER TABLE [dbo].[RolesEntreprises] DROP CONSTRAINT [FK_RolesEntreprises_EntreprisesObject];
GO

-- --------------------------------------------------
-- Dropping existing tables
-- --------------------------------------------------

IF OBJECT_ID(N'[dbo].[Entreprises]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Entreprises];
GO
IF OBJECT_ID(N'[dbo].[Roles]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Roles];
GO
IF OBJECT_ID(N'[dbo].[FormesJuridiques]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FormesJuridiques];
GO
IF OBJECT_ID(N'[dbo].[Contacts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Contacts];
GO
IF OBJECT_ID(N'[dbo].[Missions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Missions];
GO
IF OBJECT_ID(N'[dbo].[CVs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CVs];
GO
IF OBJECT_ID(N'[dbo].[CVEnvoyes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CVEnvoyes];
GO
IF OBJECT_ID(N'[dbo].[Prospection]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Prospection];
GO
IF OBJECT_ID(N'[dbo].[ContratsRecruteurs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContratsRecruteurs];
GO
IF OBJECT_ID(N'[dbo].[Entretiens]', 'U') IS NOT NULL
    DROP TABLE [dbo].[Entretiens];
GO
IF OBJECT_ID(N'[dbo].[DetailEntretiens]', 'U') IS NOT NULL
    DROP TABLE [dbo].[DetailEntretiens];
GO
IF OBJECT_ID(N'[dbo].[ListePays]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ListePays];
GO
IF OBJECT_ID(N'[dbo].[FormesJuridiqueEntreprises]', 'U') IS NOT NULL
    DROP TABLE [dbo].[FormesJuridiqueEntreprises];
GO
IF OBJECT_ID(N'[dbo].[ContactsEntreprises]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContactsEntreprises];
GO
IF OBJECT_ID(N'[dbo].[ContactsCVs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContactsCVs];
GO
IF OBJECT_ID(N'[dbo].[CVEnvoyesMissions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CVEnvoyesMissions];
GO
IF OBJECT_ID(N'[dbo].[CVsCVEnvoyes]', 'U') IS NOT NULL
    DROP TABLE [dbo].[CVsCVEnvoyes];
GO
IF OBJECT_ID(N'[dbo].[EntreprisesProspection]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EntreprisesProspection];
GO
IF OBJECT_ID(N'[dbo].[MissionsProspection]', 'U') IS NOT NULL
    DROP TABLE [dbo].[MissionsProspection];
GO
IF OBJECT_ID(N'[dbo].[EntreprisesContratsRecruteurs]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EntreprisesContratsRecruteurs];
GO
IF OBJECT_ID(N'[dbo].[ProspectionEntretiens]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ProspectionEntretiens];
GO
IF OBJECT_ID(N'[dbo].[EntretiensDetailEntretiens]', 'U') IS NOT NULL
    DROP TABLE [dbo].[EntretiensDetailEntretiens];
GO
IF OBJECT_ID(N'[dbo].[ContratsRecruteursMissions]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContratsRecruteursMissions];
GO
IF OBJECT_ID(N'[dbo].[ContactsRoles]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContactsRoles];
GO
IF OBJECT_ID(N'[dbo].[ContactsProspection]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ContactsProspection];
GO
IF OBJECT_ID(N'[dbo].[ListePaysContacts]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ListePaysContacts];
GO
IF OBJECT_ID(N'[dbo].[ListePaysEntreprises]', 'U') IS NOT NULL
    DROP TABLE [dbo].[ListePaysEntreprises];
GO
IF OBJECT_ID(N'[dbo].[RolesEntreprises]', 'U') IS NOT NULL
    DROP TABLE [dbo].[RolesEntreprises];
GO

-- --------------------------------------------------
-- Creating all tables
-- --------------------------------------------------

-- Creating table 'Entreprises'
CREATE TABLE [dbo].[Entreprises] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Capital] smallint  NULL,
    [Enseigne] nvarchar(max)  NOT NULL,
    [RepresentantLegalNom] nvarchar(max)  NULL,
    [RepresentantLegalPrenom] nvarchar(max)  NULL,
    [AdresseL1] nvarchar(max)  NULL,
    [AdresseL2] nvarchar(max)  NULL,
    [CodePostal] nvarchar(max)  NULL,
    [BoitePostale] nvarchar(max)  NULL,
    [Ville] nvarchar(max)  NULL,
    [Contacts] nvarchar(max)  NULL
);
GO

-- Creating table 'Roles'
CREATE TABLE [dbo].[Roles] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Libelle] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'FormesJuridiques'
CREATE TABLE [dbo].[FormesJuridiques] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Libelle] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Contacts'
CREATE TABLE [dbo].[Contacts] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Nom] nvarchar(max)  NOT NULL,
    [Prenom] nvarchar(max)  NOT NULL,
    [Adresse1] nvarchar(max)  NOT NULL,
    [Adresse2] nvarchar(max)  NULL,
    [CodePostal] nvarchar(max)  NOT NULL,
    [Ville] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'Missions'
CREATE TABLE [dbo].[Missions] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Titre] nvarchar(max)  NOT NULL,
    [Demandeur] smallint  NOT NULL,
    [Entreprises_Id] int  NOT NULL
);
GO

-- Creating table 'CVs'
CREATE TABLE [dbo].[CVs] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Titre] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'CVEnvoyes'
CREATE TABLE [dbo].[CVEnvoyes] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'Prospection'
CREATE TABLE [dbo].[Prospection] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'ContratsRecruteurs'
CREATE TABLE [dbo].[ContratsRecruteurs] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'Entretiens'
CREATE TABLE [dbo].[Entretiens] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'DetailEntretiens'
CREATE TABLE [dbo].[DetailEntretiens] (
    [Id] int IDENTITY(1,1) NOT NULL
);
GO

-- Creating table 'ListePays'
CREATE TABLE [dbo].[ListePays] (
    [Id] int IDENTITY(1,1) NOT NULL,
    [Libelle] nvarchar(max)  NOT NULL
);
GO

-- Creating table 'FormesJuridiqueEntreprises'
CREATE TABLE [dbo].[FormesJuridiqueEntreprises] (
    [FormesJuridique_Id] int  NOT NULL,
    [Entreprises_Id] int  NOT NULL
);
GO

-- Creating table 'ContactsEntreprises'
CREATE TABLE [dbo].[ContactsEntreprises] (
    [ContactsEntreprise_Id] int  NOT NULL,
    [Entreprises_Id] int  NOT NULL
);
GO

-- Creating table 'ContactsCVs'
CREATE TABLE [dbo].[ContactsCVs] (
    [Contacts_Id] int  NOT NULL,
    [CVs_Id] int  NOT NULL
);
GO

-- Creating table 'CVEnvoyesMissions'
CREATE TABLE [dbo].[CVEnvoyesMissions] (
    [CVEnvoyes_Id] int  NOT NULL,
    [Missions_Id] int  NOT NULL
);
GO

-- Creating table 'CVsCVEnvoyes'
CREATE TABLE [dbo].[CVsCVEnvoyes] (
    [CVs_Id] int  NOT NULL,
    [CVEnvoyes_Id] int  NOT NULL
);
GO

-- Creating table 'EntreprisesProspection'
CREATE TABLE [dbo].[EntreprisesProspection] (
    [Entreprises_Id] int  NOT NULL,
    [Prospection_Id] int  NOT NULL
);
GO

-- Creating table 'MissionsProspection'
CREATE TABLE [dbo].[MissionsProspection] (
    [Missions_Id] int  NOT NULL,
    [Prospection_Id] int  NOT NULL
);
GO

-- Creating table 'EntreprisesContratsRecruteurs'
CREATE TABLE [dbo].[EntreprisesContratsRecruteurs] (
    [Entreprises_Id] int  NOT NULL,
    [ContratsRecruteurs_Id] int  NOT NULL
);
GO

-- Creating table 'ProspectionEntretiens'
CREATE TABLE [dbo].[ProspectionEntretiens] (
    [Prospection_Id] int  NOT NULL,
    [Entretiens_Id] int  NOT NULL
);
GO

-- Creating table 'EntretiensDetailEntretiens'
CREATE TABLE [dbo].[EntretiensDetailEntretiens] (
    [Entretiens_Id] int  NOT NULL,
    [DetailEntretiens_Id] int  NOT NULL
);
GO

-- Creating table 'ContratsRecruteursMissions'
CREATE TABLE [dbo].[ContratsRecruteursMissions] (
    [ContratsRecruteurs_Id] int  NOT NULL,
    [Missions_Id] int  NOT NULL
);
GO

-- Creating table 'ContactsRoles'
CREATE TABLE [dbo].[ContactsRoles] (
    [Contacts_Id] int  NOT NULL,
    [Roles_Id] int  NOT NULL
);
GO

-- Creating table 'ContactsProspection'
CREATE TABLE [dbo].[ContactsProspection] (
    [Contacts_Id] int  NOT NULL,
    [Prospection_Id] int  NOT NULL
);
GO

-- Creating table 'ListePaysContacts'
CREATE TABLE [dbo].[ListePaysContacts] (
    [ListePays_Id] int  NOT NULL,
    [Contacts_Id] int  NOT NULL
);
GO

-- Creating table 'ListePaysEntreprises'
CREATE TABLE [dbo].[ListePaysEntreprises] (
    [ListePays_Id] int  NOT NULL,
    [Entreprises_Id] int  NOT NULL
);
GO

-- Creating table 'RolesEntreprises'
CREATE TABLE [dbo].[RolesEntreprises] (
    [Roles_Id] int  NOT NULL,
    [Entreprises_Id] int  NOT NULL
);
GO

-- --------------------------------------------------
-- Creating all PRIMARY KEY constraints
-- --------------------------------------------------

-- Creating primary key on [Id] in table 'Entreprises'
ALTER TABLE [dbo].[Entreprises]
ADD CONSTRAINT [PK_Entreprises]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Roles'
ALTER TABLE [dbo].[Roles]
ADD CONSTRAINT [PK_Roles]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'FormesJuridiques'
ALTER TABLE [dbo].[FormesJuridiques]
ADD CONSTRAINT [PK_FormesJuridiques]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Contacts'
ALTER TABLE [dbo].[Contacts]
ADD CONSTRAINT [PK_Contacts]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Missions'
ALTER TABLE [dbo].[Missions]
ADD CONSTRAINT [PK_Missions]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CVs'
ALTER TABLE [dbo].[CVs]
ADD CONSTRAINT [PK_CVs]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'CVEnvoyes'
ALTER TABLE [dbo].[CVEnvoyes]
ADD CONSTRAINT [PK_CVEnvoyes]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Prospection'
ALTER TABLE [dbo].[Prospection]
ADD CONSTRAINT [PK_Prospection]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ContratsRecruteurs'
ALTER TABLE [dbo].[ContratsRecruteurs]
ADD CONSTRAINT [PK_ContratsRecruteurs]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'Entretiens'
ALTER TABLE [dbo].[Entretiens]
ADD CONSTRAINT [PK_Entretiens]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'DetailEntretiens'
ALTER TABLE [dbo].[DetailEntretiens]
ADD CONSTRAINT [PK_DetailEntretiens]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [Id] in table 'ListePays'
ALTER TABLE [dbo].[ListePays]
ADD CONSTRAINT [PK_ListePays]
    PRIMARY KEY CLUSTERED ([Id] ASC);
GO

-- Creating primary key on [FormesJuridique_Id], [Entreprises_Id] in table 'FormesJuridiqueEntreprises'
ALTER TABLE [dbo].[FormesJuridiqueEntreprises]
ADD CONSTRAINT [PK_FormesJuridiqueEntreprises]
    PRIMARY KEY CLUSTERED ([FormesJuridique_Id], [Entreprises_Id] ASC);
GO

-- Creating primary key on [ContactsEntreprise_Id], [Entreprises_Id] in table 'ContactsEntreprises'
ALTER TABLE [dbo].[ContactsEntreprises]
ADD CONSTRAINT [PK_ContactsEntreprises]
    PRIMARY KEY CLUSTERED ([ContactsEntreprise_Id], [Entreprises_Id] ASC);
GO

-- Creating primary key on [Contacts_Id], [CVs_Id] in table 'ContactsCVs'
ALTER TABLE [dbo].[ContactsCVs]
ADD CONSTRAINT [PK_ContactsCVs]
    PRIMARY KEY CLUSTERED ([Contacts_Id], [CVs_Id] ASC);
GO

-- Creating primary key on [CVEnvoyes_Id], [Missions_Id] in table 'CVEnvoyesMissions'
ALTER TABLE [dbo].[CVEnvoyesMissions]
ADD CONSTRAINT [PK_CVEnvoyesMissions]
    PRIMARY KEY CLUSTERED ([CVEnvoyes_Id], [Missions_Id] ASC);
GO

-- Creating primary key on [CVs_Id], [CVEnvoyes_Id] in table 'CVsCVEnvoyes'
ALTER TABLE [dbo].[CVsCVEnvoyes]
ADD CONSTRAINT [PK_CVsCVEnvoyes]
    PRIMARY KEY CLUSTERED ([CVs_Id], [CVEnvoyes_Id] ASC);
GO

-- Creating primary key on [Entreprises_Id], [Prospection_Id] in table 'EntreprisesProspection'
ALTER TABLE [dbo].[EntreprisesProspection]
ADD CONSTRAINT [PK_EntreprisesProspection]
    PRIMARY KEY CLUSTERED ([Entreprises_Id], [Prospection_Id] ASC);
GO

-- Creating primary key on [Missions_Id], [Prospection_Id] in table 'MissionsProspection'
ALTER TABLE [dbo].[MissionsProspection]
ADD CONSTRAINT [PK_MissionsProspection]
    PRIMARY KEY CLUSTERED ([Missions_Id], [Prospection_Id] ASC);
GO

-- Creating primary key on [Entreprises_Id], [ContratsRecruteurs_Id] in table 'EntreprisesContratsRecruteurs'
ALTER TABLE [dbo].[EntreprisesContratsRecruteurs]
ADD CONSTRAINT [PK_EntreprisesContratsRecruteurs]
    PRIMARY KEY CLUSTERED ([Entreprises_Id], [ContratsRecruteurs_Id] ASC);
GO

-- Creating primary key on [Prospection_Id], [Entretiens_Id] in table 'ProspectionEntretiens'
ALTER TABLE [dbo].[ProspectionEntretiens]
ADD CONSTRAINT [PK_ProspectionEntretiens]
    PRIMARY KEY CLUSTERED ([Prospection_Id], [Entretiens_Id] ASC);
GO

-- Creating primary key on [Entretiens_Id], [DetailEntretiens_Id] in table 'EntretiensDetailEntretiens'
ALTER TABLE [dbo].[EntretiensDetailEntretiens]
ADD CONSTRAINT [PK_EntretiensDetailEntretiens]
    PRIMARY KEY CLUSTERED ([Entretiens_Id], [DetailEntretiens_Id] ASC);
GO

-- Creating primary key on [ContratsRecruteurs_Id], [Missions_Id] in table 'ContratsRecruteursMissions'
ALTER TABLE [dbo].[ContratsRecruteursMissions]
ADD CONSTRAINT [PK_ContratsRecruteursMissions]
    PRIMARY KEY CLUSTERED ([ContratsRecruteurs_Id], [Missions_Id] ASC);
GO

-- Creating primary key on [Contacts_Id], [Roles_Id] in table 'ContactsRoles'
ALTER TABLE [dbo].[ContactsRoles]
ADD CONSTRAINT [PK_ContactsRoles]
    PRIMARY KEY CLUSTERED ([Contacts_Id], [Roles_Id] ASC);
GO

-- Creating primary key on [Contacts_Id], [Prospection_Id] in table 'ContactsProspection'
ALTER TABLE [dbo].[ContactsProspection]
ADD CONSTRAINT [PK_ContactsProspection]
    PRIMARY KEY CLUSTERED ([Contacts_Id], [Prospection_Id] ASC);
GO

-- Creating primary key on [ListePays_Id], [Contacts_Id] in table 'ListePaysContacts'
ALTER TABLE [dbo].[ListePaysContacts]
ADD CONSTRAINT [PK_ListePaysContacts]
    PRIMARY KEY CLUSTERED ([ListePays_Id], [Contacts_Id] ASC);
GO

-- Creating primary key on [ListePays_Id], [Entreprises_Id] in table 'ListePaysEntreprises'
ALTER TABLE [dbo].[ListePaysEntreprises]
ADD CONSTRAINT [PK_ListePaysEntreprises]
    PRIMARY KEY CLUSTERED ([ListePays_Id], [Entreprises_Id] ASC);
GO

-- Creating primary key on [Roles_Id], [Entreprises_Id] in table 'RolesEntreprises'
ALTER TABLE [dbo].[RolesEntreprises]
ADD CONSTRAINT [PK_RolesEntreprises]
    PRIMARY KEY CLUSTERED ([Roles_Id], [Entreprises_Id] ASC);
GO

-- --------------------------------------------------
-- Creating all FOREIGN KEY constraints
-- --------------------------------------------------

-- Creating foreign key on [FormesJuridique_Id] in table 'FormesJuridiqueEntreprises'
ALTER TABLE [dbo].[FormesJuridiqueEntreprises]
ADD CONSTRAINT [FK_FormesJuridiqueEntreprises_FormesJuridique]
    FOREIGN KEY ([FormesJuridique_Id])
    REFERENCES [dbo].[FormesJuridiques]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Entreprises_Id] in table 'FormesJuridiqueEntreprises'
ALTER TABLE [dbo].[FormesJuridiqueEntreprises]
ADD CONSTRAINT [FK_FormesJuridiqueEntreprises_Entreprises]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_FormesJuridiqueEntreprises_Entreprises'
CREATE INDEX [IX_FK_FormesJuridiqueEntreprises_Entreprises]
ON [dbo].[FormesJuridiqueEntreprises]
    ([Entreprises_Id]);
GO

-- Creating foreign key on [ContactsEntreprise_Id] in table 'ContactsEntreprises'
ALTER TABLE [dbo].[ContactsEntreprises]
ADD CONSTRAINT [FK_ContactsEntreprises_Contacts]
    FOREIGN KEY ([ContactsEntreprise_Id])
    REFERENCES [dbo].[Contacts]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Entreprises_Id] in table 'ContactsEntreprises'
ALTER TABLE [dbo].[ContactsEntreprises]
ADD CONSTRAINT [FK_ContactsEntreprises_Entreprises]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ContactsEntreprises_Entreprises'
CREATE INDEX [IX_FK_ContactsEntreprises_Entreprises]
ON [dbo].[ContactsEntreprises]
    ([Entreprises_Id]);
GO

-- Creating foreign key on [Entreprises_Id] in table 'Missions'
ALTER TABLE [dbo].[Missions]
ADD CONSTRAINT [FK_MissionsEntreprises]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_MissionsEntreprises'
CREATE INDEX [IX_FK_MissionsEntreprises]
ON [dbo].[Missions]
    ([Entreprises_Id]);
GO

-- Creating foreign key on [Contacts_Id] in table 'ContactsCVs'
ALTER TABLE [dbo].[ContactsCVs]
ADD CONSTRAINT [FK_ContactsCVs_Contacts]
    FOREIGN KEY ([Contacts_Id])
    REFERENCES [dbo].[Contacts]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [CVs_Id] in table 'ContactsCVs'
ALTER TABLE [dbo].[ContactsCVs]
ADD CONSTRAINT [FK_ContactsCVs_CVs]
    FOREIGN KEY ([CVs_Id])
    REFERENCES [dbo].[CVs]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ContactsCVs_CVs'
CREATE INDEX [IX_FK_ContactsCVs_CVs]
ON [dbo].[ContactsCVs]
    ([CVs_Id]);
GO

-- Creating foreign key on [CVEnvoyes_Id] in table 'CVEnvoyesMissions'
ALTER TABLE [dbo].[CVEnvoyesMissions]
ADD CONSTRAINT [FK_CVEnvoyesMissions_CVEnvoyes]
    FOREIGN KEY ([CVEnvoyes_Id])
    REFERENCES [dbo].[CVEnvoyes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Missions_Id] in table 'CVEnvoyesMissions'
ALTER TABLE [dbo].[CVEnvoyesMissions]
ADD CONSTRAINT [FK_CVEnvoyesMissions_Missions]
    FOREIGN KEY ([Missions_Id])
    REFERENCES [dbo].[Missions]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_CVEnvoyesMissions_Missions'
CREATE INDEX [IX_FK_CVEnvoyesMissions_Missions]
ON [dbo].[CVEnvoyesMissions]
    ([Missions_Id]);
GO

-- Creating foreign key on [CVs_Id] in table 'CVsCVEnvoyes'
ALTER TABLE [dbo].[CVsCVEnvoyes]
ADD CONSTRAINT [FK_CVsCVEnvoyes_CVs]
    FOREIGN KEY ([CVs_Id])
    REFERENCES [dbo].[CVs]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [CVEnvoyes_Id] in table 'CVsCVEnvoyes'
ALTER TABLE [dbo].[CVsCVEnvoyes]
ADD CONSTRAINT [FK_CVsCVEnvoyes_CVEnvoyes]
    FOREIGN KEY ([CVEnvoyes_Id])
    REFERENCES [dbo].[CVEnvoyes]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_CVsCVEnvoyes_CVEnvoyes'
CREATE INDEX [IX_FK_CVsCVEnvoyes_CVEnvoyes]
ON [dbo].[CVsCVEnvoyes]
    ([CVEnvoyes_Id]);
GO

-- Creating foreign key on [Entreprises_Id] in table 'EntreprisesProspection'
ALTER TABLE [dbo].[EntreprisesProspection]
ADD CONSTRAINT [FK_EntreprisesProspection_Entreprises]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Prospection_Id] in table 'EntreprisesProspection'
ALTER TABLE [dbo].[EntreprisesProspection]
ADD CONSTRAINT [FK_EntreprisesProspection_Prospection]
    FOREIGN KEY ([Prospection_Id])
    REFERENCES [dbo].[Prospection]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_EntreprisesProspection_Prospection'
CREATE INDEX [IX_FK_EntreprisesProspection_Prospection]
ON [dbo].[EntreprisesProspection]
    ([Prospection_Id]);
GO

-- Creating foreign key on [Missions_Id] in table 'MissionsProspection'
ALTER TABLE [dbo].[MissionsProspection]
ADD CONSTRAINT [FK_MissionsProspection_Missions]
    FOREIGN KEY ([Missions_Id])
    REFERENCES [dbo].[Missions]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Prospection_Id] in table 'MissionsProspection'
ALTER TABLE [dbo].[MissionsProspection]
ADD CONSTRAINT [FK_MissionsProspection_Prospection]
    FOREIGN KEY ([Prospection_Id])
    REFERENCES [dbo].[Prospection]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_MissionsProspection_Prospection'
CREATE INDEX [IX_FK_MissionsProspection_Prospection]
ON [dbo].[MissionsProspection]
    ([Prospection_Id]);
GO

-- Creating foreign key on [Entreprises_Id] in table 'EntreprisesContratsRecruteurs'
ALTER TABLE [dbo].[EntreprisesContratsRecruteurs]
ADD CONSTRAINT [FK_EntreprisesContratsRecruteurs_Entreprises]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [ContratsRecruteurs_Id] in table 'EntreprisesContratsRecruteurs'
ALTER TABLE [dbo].[EntreprisesContratsRecruteurs]
ADD CONSTRAINT [FK_EntreprisesContratsRecruteurs_ContratsRecruteurs]
    FOREIGN KEY ([ContratsRecruteurs_Id])
    REFERENCES [dbo].[ContratsRecruteurs]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_EntreprisesContratsRecruteurs_ContratsRecruteurs'
CREATE INDEX [IX_FK_EntreprisesContratsRecruteurs_ContratsRecruteurs]
ON [dbo].[EntreprisesContratsRecruteurs]
    ([ContratsRecruteurs_Id]);
GO

-- Creating foreign key on [Prospection_Id] in table 'ProspectionEntretiens'
ALTER TABLE [dbo].[ProspectionEntretiens]
ADD CONSTRAINT [FK_ProspectionEntretiens_Prospection]
    FOREIGN KEY ([Prospection_Id])
    REFERENCES [dbo].[Prospection]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Entretiens_Id] in table 'ProspectionEntretiens'
ALTER TABLE [dbo].[ProspectionEntretiens]
ADD CONSTRAINT [FK_ProspectionEntretiens_Entretiens]
    FOREIGN KEY ([Entretiens_Id])
    REFERENCES [dbo].[Entretiens]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ProspectionEntretiens_Entretiens'
CREATE INDEX [IX_FK_ProspectionEntretiens_Entretiens]
ON [dbo].[ProspectionEntretiens]
    ([Entretiens_Id]);
GO

-- Creating foreign key on [Entretiens_Id] in table 'EntretiensDetailEntretiens'
ALTER TABLE [dbo].[EntretiensDetailEntretiens]
ADD CONSTRAINT [FK_EntretiensDetailEntretiens_Entretiens]
    FOREIGN KEY ([Entretiens_Id])
    REFERENCES [dbo].[Entretiens]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [DetailEntretiens_Id] in table 'EntretiensDetailEntretiens'
ALTER TABLE [dbo].[EntretiensDetailEntretiens]
ADD CONSTRAINT [FK_EntretiensDetailEntretiens_DetailEntretiens]
    FOREIGN KEY ([DetailEntretiens_Id])
    REFERENCES [dbo].[DetailEntretiens]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_EntretiensDetailEntretiens_DetailEntretiens'
CREATE INDEX [IX_FK_EntretiensDetailEntretiens_DetailEntretiens]
ON [dbo].[EntretiensDetailEntretiens]
    ([DetailEntretiens_Id]);
GO

-- Creating foreign key on [ContratsRecruteurs_Id] in table 'ContratsRecruteursMissions'
ALTER TABLE [dbo].[ContratsRecruteursMissions]
ADD CONSTRAINT [FK_ContratsRecruteursMissions_ContratsRecruteurs]
    FOREIGN KEY ([ContratsRecruteurs_Id])
    REFERENCES [dbo].[ContratsRecruteurs]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Missions_Id] in table 'ContratsRecruteursMissions'
ALTER TABLE [dbo].[ContratsRecruteursMissions]
ADD CONSTRAINT [FK_ContratsRecruteursMissions_Missions]
    FOREIGN KEY ([Missions_Id])
    REFERENCES [dbo].[Missions]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ContratsRecruteursMissions_Missions'
CREATE INDEX [IX_FK_ContratsRecruteursMissions_Missions]
ON [dbo].[ContratsRecruteursMissions]
    ([Missions_Id]);
GO

-- Creating foreign key on [Contacts_Id] in table 'ContactsRoles'
ALTER TABLE [dbo].[ContactsRoles]
ADD CONSTRAINT [FK_ContactsRoles_Contacts]
    FOREIGN KEY ([Contacts_Id])
    REFERENCES [dbo].[Contacts]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Roles_Id] in table 'ContactsRoles'
ALTER TABLE [dbo].[ContactsRoles]
ADD CONSTRAINT [FK_ContactsRoles_Roles]
    FOREIGN KEY ([Roles_Id])
    REFERENCES [dbo].[Roles]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ContactsRoles_Roles'
CREATE INDEX [IX_FK_ContactsRoles_Roles]
ON [dbo].[ContactsRoles]
    ([Roles_Id]);
GO

-- Creating foreign key on [Contacts_Id] in table 'ContactsProspection'
ALTER TABLE [dbo].[ContactsProspection]
ADD CONSTRAINT [FK_ContactsProspection_Contacts]
    FOREIGN KEY ([Contacts_Id])
    REFERENCES [dbo].[Contacts]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Prospection_Id] in table 'ContactsProspection'
ALTER TABLE [dbo].[ContactsProspection]
ADD CONSTRAINT [FK_ContactsProspection_Prospection]
    FOREIGN KEY ([Prospection_Id])
    REFERENCES [dbo].[Prospection]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ContactsProspection_Prospection'
CREATE INDEX [IX_FK_ContactsProspection_Prospection]
ON [dbo].[ContactsProspection]
    ([Prospection_Id]);
GO

-- Creating foreign key on [ListePays_Id] in table 'ListePaysContacts'
ALTER TABLE [dbo].[ListePaysContacts]
ADD CONSTRAINT [FK_ListePaysContacts_ListePaysObject]
    FOREIGN KEY ([ListePays_Id])
    REFERENCES [dbo].[ListePays]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Contacts_Id] in table 'ListePaysContacts'
ALTER TABLE [dbo].[ListePaysContacts]
ADD CONSTRAINT [FK_ListePaysContacts_ContactsObject]
    FOREIGN KEY ([Contacts_Id])
    REFERENCES [dbo].[Contacts]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ListePaysContacts_ContactsObject'
CREATE INDEX [IX_FK_ListePaysContacts_ContactsObject]
ON [dbo].[ListePaysContacts]
    ([Contacts_Id]);
GO

-- Creating foreign key on [ListePays_Id] in table 'ListePaysEntreprises'
ALTER TABLE [dbo].[ListePaysEntreprises]
ADD CONSTRAINT [FK_ListePaysEntreprises_ListePaysObject]
    FOREIGN KEY ([ListePays_Id])
    REFERENCES [dbo].[ListePays]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Entreprises_Id] in table 'ListePaysEntreprises'
ALTER TABLE [dbo].[ListePaysEntreprises]
ADD CONSTRAINT [FK_ListePaysEntreprises_EntreprisesObject]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_ListePaysEntreprises_EntreprisesObject'
CREATE INDEX [IX_FK_ListePaysEntreprises_EntreprisesObject]
ON [dbo].[ListePaysEntreprises]
    ([Entreprises_Id]);
GO

-- Creating foreign key on [Roles_Id] in table 'RolesEntreprises'
ALTER TABLE [dbo].[RolesEntreprises]
ADD CONSTRAINT [FK_RolesEntreprises_RolesObject]
    FOREIGN KEY ([Roles_Id])
    REFERENCES [dbo].[Roles]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating foreign key on [Entreprises_Id] in table 'RolesEntreprises'
ALTER TABLE [dbo].[RolesEntreprises]
ADD CONSTRAINT [FK_RolesEntreprises_EntreprisesObject]
    FOREIGN KEY ([Entreprises_Id])
    REFERENCES [dbo].[Entreprises]
        ([Id])
    ON DELETE NO ACTION ON UPDATE NO ACTION;
GO

-- Creating non-clustered index for FOREIGN KEY 'FK_RolesEntreprises_EntreprisesObject'
CREATE INDEX [IX_FK_RolesEntreprises_EntreprisesObject]
ON [dbo].[RolesEntreprises]
    ([Entreprises_Id]);
GO

-- --------------------------------------------------
-- Script has ended
-- --------------------------------------------------